package com.hassean.we.admin.service.impl;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hassean.we.admin.mapper.TbSimInfoMapper;
import com.hassean.we.admin.model.entity.TbSimInfo;
import com.hassean.we.admin.service.TbSimInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yajun
 * @since 2019-03-29
 */
@Service
public class TbSimInfoServiceImpl extends ServiceImpl<TbSimInfoMapper, TbSimInfo> implements TbSimInfoService {
    @Autowired
    TbSimInfoMapper tbSimInfoMapper;

    @Override
    public List<Map<String, Object>> selectTbSimInfoIdByPhone(String phone) {

        List<Map<String, Object>> list = tbSimInfoMapper.selectTbSimInfoIdByPhone(phone);

        return list;
    }

    @Override
    public List<Map<String, Object>> getPhoneByTerminalId(Long terminalId) {
        List<Map<String, Object>> list = tbSimInfoMapper.getPhoneByTerminalId(terminalId);

        return list;

    }

    @Override
    public Long insertAndReturnId(TbSimInfo tbSimInfo) {
        //电话号码判重
        TbSimInfo simInfo= tbSimInfoMapper.selectOne(tbSimInfo);
        Long id = 0L;
        Long simInfoId =null;
        if(simInfo!=null){
            return id ;
        }else{
            try{

                id= tbSimInfoMapper.insertAndReturnId(tbSimInfo);
                if(id!=0L){
                    simInfoId = tbSimInfo.getSimInfoId();
                }

            }catch (Exception e){
                e.printStackTrace();
            }
            return simInfoId;

        }

    }

}
